package com.contain.minio.auto;

import com.contain.minio.bean.HelloProperties;
import com.contain.minio.properties.FaceScannerRegister;
import com.contain.minio.service.HelloService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * @Auther: tianchao
 * @Date: 2021/8/19 21:22
 * @Description:
 */
@Configuration
//@ConditionalOnMissingBean(HelloService.class) 放在这里是不对的 导致整个引入该启动器的工程因为找不到HelloProperties报错
@EnableConfigurationProperties(HelloProperties.class)
@Import({FaceScannerRegister.class})
public class HelloServiceAutoConfiguration {

    /**
     * 放在这里的作用是 不至于引入的工程报错HelloProperties不存在，而且可以灵活配置
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(HelloService.class)
    public HelloService helloService(){
        HelloService helloService = new HelloService();
        return helloService;
    }

}
